package com.leyou.search.web;

import com.leyou.common.vo.PageResult;
import com.leyou.search.pojo.SearchRequest;
import com.leyou.search.pojo.Goods;
import com.leyou.search.service.GoodsSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName SearchController
 * @Date 2019/2/17 16:58
 */
@RestController
public class SearchController {

    @Autowired
    private GoodsSearchService searchService;

    /**
     * 根据关键字搜索索引库
     * @param request
     * @return
     */
    @PostMapping("page")
    public ResponseEntity<PageResult<Goods>> queryGoodsByKey(@RequestBody SearchRequest request) {
        return ResponseEntity.ok(searchService.queryGoodsByKey(request));
    }
}
